//
//  UIBarButtonItem+extension.swift
//  weibo
//
//  Created by 胡古古 on 2017/6/4.
//  Copyright © 2017年 hugugu. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(target: Any?, action: Selector,title:String,imageName:String? = nil) {
        
        self.init()
        
        let button = UIButton()
        
        button.addTarget(target, action: action, for: .touchUpInside)
        
        if imageName != nil {
            
            button.setImage(UIImage(named:imageName!), for: .normal)
        }
        
        button.setTitle(title, for: .normal)
        button.setTitleColor(UIColor.darkGray, for: .normal)
        button.setTitleColor(UIColor.orange, for: .highlighted)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        button.sizeToFit()
        
        self.customView = button
        
        
    }
    
    
}
